import { get, post } from '../utils/request';

const API_URL = 'https://test.youbaobao.xyz:18081'

export function getHomeData(parmas) {
    return get(`${API_URL}/book/home/v2`, parmas)
}

export function recommend() {
    return get(`${API_URL}/book/home/recommend/v2`)
}

export function freeRead() {
    return get(`${API_URL}/book/home/freeRead/v2`)
}

export function hotBook() {
    return get(`${API_URL}/book/home/hotBook/v2`)
}

export function getOpenId(code) {
    let APP_ID = 'wx671824556a79681d';
    let APP_SECRET = '2f4d2869419fc7b23f4d85a81ad8dad7';
    return get(`${API_URL}/openId/get`, {
        appId: APP_ID,
        secret: APP_SECRET,
        code
    })
}

export function register(openId, userInfo) {
    return post(`${API_URL}/user/register`, {
        openId,
        platform: mpvuePlatform,
        ...userInfo
    })
}

export function search(params) {
    return get(`${API_URL}/book/search`, params)
}

export function hotSearch() {
    return get(`${API_URL}/book/hot-search`)
}

export function bookDetail(params) {
    return get(`${API_URL}/book/detail`, params)
}

export function bookRankSave(params) {
    return get(`${API_URL}/book/rank/save`, params)
}

export function bookContents(params) {
    return get(`${API_URL}/book/contents`, params)
}

export function bookIsInShelf(params) {//bookShelf
    return get(`${API_URL}/book/shelf/get`, params)
}

export function bookShelfSave(params) {
    return get(`${API_URL}/book/shelf/save`, {
        shelf: JSON.stringify(params)
    })
}

export function bookShelfRemove(params) {
    return get(`${API_URL}/book/shelf/remove`, {
        shelf: JSON.stringify(params)
    })
}

export function searchList(params) {
    return get(`${API_URL}/book/search-list`, params)
}

export function categoryList() {
    return get(`${API_URL}/book/category/list/v2`)
}

export function userDay(params) {
    return get(`${API_URL}/user/day`, params)
}